"""
7-5 冒泡排序
本题目要求读入N个整数，
采用冒泡排序（上升法，即每轮得到一个最小值）进行排序，
输出前3轮排序后的结果。
"""


# Python的赋值语句的功能是更加强大
def swap(a, b):
    a, b = b, a
    return a, b


def single_bubble_sort(list):
    length = len(list)
    for i in range(length-1):
        if list[length-1-i] < list[length-1-i-1]:
            list[length-1-i], list[length-1-i-1] \
                = swap(list[length-1-i], list[length-1-i-1])
    return list


def resolution1():
    # input
    n = int(input())
    str_list = input().split(" ")
    number_list = []
    for item in str_list:
        number_list.append(int(item))
    # solve
    for _ in range(3):
        number_list = single_bubble_sort(number_list)
        # output
        for item in number_list:
            print(f"{item} ", end="")
        print()


if __name__ == '__main__':
    resolution1()